﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using KenLib.BusinessManager;
using KenLib.BusinessObject;
using DataInfo;
using System.Web.UI.MobileControls;
using System.Collections.Generic;
using System.Drawing;

public partial class JOINT_frmJ_TraineeAppAssignCheck : System.Web.UI.Page
{
    応募情報Manager _応募情報Manager = new 応募情報Manager();
    本社情報Manager _本社情報Manager = new 本社情報Manager();
    面接詳細情報Manager _面接詳細情報Manager = new 面接詳細情報Manager();
    面接情報Manager _面接情報Manager = new 面接情報Manager();
    /// <summary>
    /// Coder: Thanh Dong
    /// Event: Page load
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        ((JOINT_MstPage_JOINT)this.Master).HideLiArea("frmJ_TraineeInterviewList");
        ((JOINT_MstPage_JOINT)this.Master).changeTitle("面接企業確定");
        if (Session["人コード"] == null)
        {
            Response.Redirect("../frmD_Login.aspx");
        }
        RFV_ddl_組合選択.ErrorMessage = GetError("ER00007");
        RFV_組合員企業選択.ErrorMessage = GetError("ER00007");
        RFV_面接日.ErrorMessage = GetError("ER00007");
        ddl_組合選択.Focus();
        if (!IsPostBack)
        {
            Load_面接日(-1, -1);
            ViewState["update"] = 0;
            ViewState["pageindex"] = 0;
            Load_ddl_組合選択();
            Load_ddl_組合員企業選択(-1);
            string strTableHeader = "氏名,年齢,数学テスト,性格（YG),最終学歴,ID発行機関,組合名,企業名";
            ShowGridViewNotClassEmpty(grv, strTableHeader, "データがありません。");
        }
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Show data in gridview
    /// </summary>
    /// <param name="int_団体ID"></param>
    /// <param name="int_企業ID"></param>
    /// <param name="dt_面接日"></param>
    public void ShowGrv(int int_団体ID, int int_企業ID, DateTime dt_面接日)
    {
        DataTable dt = new DataTable();
        dt = _応募情報Manager.frmJ_TraineeAppAssignCheck_Select_Grv(int_団体ID, int_企業ID, Convert.ToDateTime(dt_面接日));
        string strTableHeader = "氏名,年齢,数学テスト,性格（YG),最終学歴,ID発行機関,組合名,企業名";
        if (dt.Rows.Count > 0)
        {
            //List<string> list = new List<string>();
            //for (int i = 0; i < dt.Rows.Count; i++)
            //{
            //    string strValueInFirstRow = dt.Rows[i]["氏名"].ToString() + "," + dt.Rows[i]["年齢"].ToString() + "," + dt.Rows[i]["数学テスト"].ToString() + "," + dt.Rows[i]["性格（YG)"].ToString() + "," + dt.Rows[i]["最終学歴"].ToString() + "," + dt.Rows[i]["ID発行機関"].ToString() + "," + dt.Rows[i]["組合名"].ToString() + "," + dt.Rows[i]["企業名"].ToString();
            //    list.Add(strValueInFirstRow);
            //}
            //ShowGridViewNotClass(grv, strTableHeader, list);
            grv.DataSource = dt;
            grv.DataBind();
            ViewState["update"] = 1;
        }
        else
        {
            ShowGridViewNotClassEmpty(grv, strTableHeader, "データがありません。");
            ViewState["update"] = 0;
        }
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Load data in dropdownlist 組合選択
    /// </summary>
    public void Load_ddl_組合選択()
    {
        DataTable dt = new DataTable();
        //dt = _本社情報Manager.frmJ_TraineeAppAssignCheck_Select_組合選択();
        dt = _本社情報Manager.frmJ_TraineeSearch_Select_dll組合選択();
        ddl_組合選択.DataSource = dt;
        ddl_組合選択.DataTextField = "企業名";
        ddl_組合選択.DataValueField = "企業ID";
        ddl_組合選択.DataBind();
        ListItem item = new ListItem("[選択]", "-1");
        item.Selected = true;
        ddl_組合選択.Items.Insert(0, item);
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Load data in dropdownlist 組合員企業選択
    /// </summary>
    public void Load_ddl_組合員企業選択(int 企業ID)
    {
        DataTable dt = new DataTable();
        //dt = _本社情報Manager.frmJ_TraineeAppAssignCheck_Select_組合員企業選択();
        dt = _本社情報Manager.frmJ_TraineeSearch_Select_dll組合員企業選択(企業ID);
        ddl_組合員企業選択.DataSource = dt;
        ddl_組合員企業選択.DataTextField = "企業名";
        ddl_組合員企業選択.DataValueField = "企業ID";
        ddl_組合員企業選択.DataBind();
        ListItem item = new ListItem("[選択]", "-1");
        item.Selected = true;
        ddl_組合員企業選択.Items.Insert(0, item);
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Show data in gridview
    /// </summary>
    /// <param name="grv"></param>
    /// <param name="strTableHeader"></param>
    /// <param name="list"></param>
    public void ShowGridViewNotClass(GridView grv, string strTableHeader, List<string> list)
    {
        DataTable dt = new DataTable();
        string[] arrColumnNames = strTableHeader.Split(',');
        foreach (string str in arrColumnNames)
        {
            dt.Columns.Add(str);
        }
        for (int i = 0; i < list.Count; i++)
        {
            DataRow r = dt.NewRow();
            string[] arrFristRowValues = list[i].Split(',');
            for (int j = 0; j < arrColumnNames.Length; j++)
            {
                if (j < arrFristRowValues.Length)
                {
                    r[arrColumnNames[j]] = arrFristRowValues[j];
                }
            }
            dt.Rows.InsertAt(r, i);
        }
        grv.DataSource = dt;
        grv.DataBind();
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Load gridview empty
    /// </summary>
    /// <param name="grv"></param>
    /// <param name="strTableHeader"></param>
    /// <param name="strEmpty"></param>
    public void ShowGridViewNotClassEmpty(GridView grv, string strTableHeader, string strEmpty)
    {
        DataTable dt = new DataTable();
        string[] arrColumnNames = strTableHeader.Split(',');
        foreach (string str in arrColumnNames)
        {
            dt.Columns.Add(str);
        }
        grv.ShowFooter = false;
        DataRow r = dt.NewRow();
        dt.Rows.InsertAt(r, 0);
        grv.DataSource = dt;
        grv.DataBind();
        grv.Rows[0].Cells.Clear();
        TableCell cell = new TableCell();
        cell.ColumnSpan = grv.Columns.Count + 1;
        cell.Text = strEmpty;
        grv.Rows[0].Cells.Add(cell);
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Get error message from id
    /// </summary>
    /// <param name="errorid"></param>
    /// <returns></returns>
    public String GetError(string errorid)
    {
        string error = "";
        Error er = new Error();
        er.ErrorID = errorid;
        ErrorManager frm_error = new ErrorManager();
        DataTable dt = frm_error.getError(er);
        if (dt.Rows.Count > 0)
        {
            error = dt.Rows[0][2].ToString();
        }
        return error;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Event: Show data of dropdownlist in gridview
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            Control ctrl1 = e.Row.FindControl("ddl_組合名");
            if (ctrl1 != null)
            {
                DropDownList dd = ctrl1 as DropDownList;
                DataTable dt = new DataTable();
                dt = _本社情報Manager.frmJ_TraineeSearch_Select_dll組合選択();
                dd.DataSource = dt;
                dd.DataTextField = "企業名";
                dd.DataValueField = "企業ID";
                dd.DataBind();
                ListItem item = new ListItem("[選択]", "-1");
                item.Selected = true;
                dd.Items.Insert(0, item);
                dd.ValidationGroup = e.Row.RowIndex.ToString();

            }

            Control ctrl2 = e.Row.FindControl("ddl_企業名");
            if (ctrl2 != null)
            {
                DropDownList dd = ctrl2 as DropDownList;
                //Binding the Dropdown with Dummy data.
                DataTable dt = new DataTable();
                dt = _本社情報Manager.frmJ_TraineeSearch_Select_dll組合員企業選択(Convert.ToInt32(ddl_組合選択.SelectedValue));
                dd.DataSource = dt;
                dd.DataTextField = "企業名";
                dd.DataValueField = "企業ID";
                dd.DataBind();
                ListItem item = new ListItem("[選択]", "-1");
                item.Selected = true;
                dd.Items.Insert(0, item);
                dd.ValidationGroup = e.Row.RowIndex.ToString();
            }


        }
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Event: update data Multi-Record in table 面接詳細情報
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn確定_Click(object sender, EventArgs e)
    {
        DateTime dt1 = new DateTime();
        DateTime.TryParse(Convert.ToString(ddl_面接日.SelectedValue), out dt1);
        if (String.Format("{0:yyyy/MM/dd}", dt1) == "0001/01/01")
        {
            string strTableHeader = "氏名,年齢,数学テスト,性格（YG),最終学歴,ID発行機関,組合名,企業名";
            ShowGridViewNotClassEmpty(grv, strTableHeader, "データがありません。");
            ddl_面接日.Focus();
        }
        else
        {
            int temp = Convert.ToInt32(ViewState["update"]);
            DataTable dt = new DataTable();
            dt = _応募情報Manager.frmJ_TraineeAppAssignCheck_Select_Grv(Convert.ToInt32(ddl_組合選択.SelectedValue), Convert.ToInt32(ddl_組合員企業選択.SelectedValue), Convert.ToDateTime(ddl_面接日.SelectedValue));
            if (temp == 1 && dt.Rows.Count > 0)
            {
                if (CheckddlEmpty(grv) == false)
                {
                    //List<List<int>> list = GetChangeDropdownlist(grv);
                    //Session["frmJ_TraineeAppAssignCheck_list"] = list; 
                    ChangeBackgroundDropdowlistEmpty(grv);
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('必須項目です、選択してください。');</script>");
                }
                else
                {
                    int pageindex = Convert.ToInt32(ViewState["pageindex"]);
                    int rows = 0;
                    List<List<int>> listArray = new List<List<int>>();
                    for (int i = 0; i < grv.Rows.Count; i++)
                    {
                        rows = 10 * (pageindex) + i;
                        Control ctrl1 = grv.Rows[i].FindControl("ddl_組合名");
                        DropDownList dd1 = ctrl1 as DropDownList;
                        Control ctrl2 = grv.Rows[i].FindControl("ddl_企業名");
                        DropDownList dd2 = ctrl2 as DropDownList;
                        List<int> list = new List<int>();
                        int ID = Convert.ToInt32(dt.Rows[rows]["ID"]);
                        int 団体ID = Convert.ToInt32(dt.Rows[rows]["団体ID"]);
                        int 団体ID_new = Convert.ToInt32(dd1.SelectedValue);
                        int 企業ID = Convert.ToInt32(dt.Rows[rows]["企業ID"]);
                        int 企業ID_new = Convert.ToInt32(dd2.SelectedValue);
                        int 応募情報ID = Convert.ToInt32(dt.Rows[rows]["応募情報ID"]);
                        list.Add(ID);
                        list.Add(団体ID);
                        list.Add(団体ID_new);
                        list.Add(企業ID);
                        list.Add(企業ID_new);
                        list.Add(応募情報ID);
                        listArray.Add(list);

                    }

                    if (frmJ_TraineeAppAssignCheck_Update(listArray) == 1)
                    {
                        ViewState["pageindex"] = 0;
                        BindDDLGridView();
                    }

                }
            }
            else
            {
                string strTableHeader = "氏名,年齢,数学テスト,性格（YG),最終学歴,ID発行機関,組合名,企業名";
                ShowGridViewNotClassEmpty(grv, strTableHeader, "データがありません。");
                ViewState["update"] = 0;
            }
        }
       

    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Fucnction: Check update 1 record in table 面接詳細情報
    /// </summary>
    /// <param name="ID"></param>
    /// <param name="団体ID"></param>
    /// <param name="団体ID_new"></param>
    /// <param name="企業ID"></param>
    /// <param name="企業ID_new"></param>
    /// <param name="応募情報ID"></param>
    /// <returns></returns>
    public int frmJ_TraineeAppAssignCheck_Update(int ID, int 団体ID, int 団体ID_new, int 企業ID, int 企業ID_new, int 応募情報ID)
    {
        if (_面接詳細情報Manager.frmJ_TraineeAppAssignCheck_Update(ID, 団体ID, 団体ID_new, 企業ID, 企業ID_new, 応募情報ID) == 1)
        {
            return 1;
        }
        return 0;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Check update data Multi-Record in table 面接詳細情報
    /// </summary>
    /// <param name="list"></param>
    /// <returns></returns>
    public int frmJ_TraineeAppAssignCheck_Update(List<List<int>> list)
    {
        int flag = 1;
        for (int i = 0; i < list.Count; i++)
        {
            int ID = Convert.ToInt32(list[i][0]);
            int 団体ID = Convert.ToInt32(list[i][1]);
            int 団体ID_new = Convert.ToInt32(list[i][2]);
            int 企業ID = Convert.ToInt32(list[i][3]);
            int 企業ID_new = Convert.ToInt32(list[i][4]);
            int 応募情報ID = Convert.ToInt32(list[i][5]);
            if (frmJ_TraineeAppAssignCheck_Update(ID, 団体ID, 団体ID_new, 企業ID, 企業ID_new, 応募情報ID) != 1)
            {
                flag = 0;
            }
        }
        return flag;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Event: Page Index Changing
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grv_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        ViewState["pageindex"] = e.NewPageIndex;
        grv.PageIndex = e.NewPageIndex;
        ShowGrv(Convert.ToInt32(ddl_組合選択.SelectedValue), Convert.ToInt32(ddl_組合員企業選択.SelectedValue), Convert.ToDateTime(ddl_面接日.SelectedValue));
        BindDDLGridView();
        ChangeBackgroundDropdowlistEmpty(grv);
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Load data in dropdownlist (dropdownlist on grid view )
    /// </summary>
    public void BindDDLGridView()
    {
        DataTable dt = new DataTable();
        dt = _応募情報Manager.frmJ_TraineeAppAssignCheck_Select_Grv(Convert.ToInt32(ddl_組合選択.SelectedValue), Convert.ToInt32(ddl_組合員企業選択.SelectedValue), Convert.ToDateTime(ddl_面接日.SelectedValue));
        //grv.DataSource = dt;
        //grv.DataBind();
        if (dt.Rows.Count > 0)
        {

            for (int i = 0; i < grv.Rows.Count; i++)
            {
                Control ctrl1 = grv.Rows[i].FindControl("ddl_組合名");
                if (ctrl1 != null)
                {
                    DropDownList dd = ctrl1 as DropDownList;
                    string abc = dt.Rows[i]["組合名"].ToString();
                    ListItem lst = dd.Items.FindByText(abc);
                    dd.SelectedIndex = dd.Items.IndexOf(lst);
                }

                Control ctrl2 = grv.Rows[i].FindControl("ddl_企業名");
                if (ctrl2 != null)
                {
                    DropDownList dd = ctrl2 as DropDownList;
                    string abc = dt.Rows[i]["企業名"].ToString();
                    ListItem lst = dd.Items.FindByText(abc);
                    dd.SelectedIndex = dd.Items.IndexOf(lst);
                }
            }
            ViewState["update"] = 1;


        }
        else
        {
            string strTableHeader = "氏名,年齢,数学テスト,性格（YG),最終学歴,ID発行機関,組合名,企業名";
            ShowGridViewNotClassEmpty(grv, strTableHeader, "データがありません。");
            ViewState["update"] = 0;
        }

    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Event: Search data
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    //protected void btn検索_Click(object sender, EventArgs e)
    //{
    //    ShowGrv(Convert.ToInt32(ddl_組合選択.SelectedValue), Convert.ToInt32(ddl_組合員企業選択.SelectedValue), Convert.ToDateTime(ddl_面接日.SelectedValue));
    //    BindDDLGridView();
    //    ViewState["pageindex"] = 0;
    //}

    /// <summary>
    /// Coder: Thanh Dong
    /// Event: Delete row in gridview where id
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grv_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        DataTable dt = new DataTable();
        dt = _応募情報Manager.frmJ_TraineeAppAssignCheck_Select_Grv(Convert.ToInt32(ddl_組合選択.SelectedValue), Convert.ToInt32(ddl_組合員企業選択.SelectedValue), Convert.ToDateTime(ddl_面接日.Text));
        int numberpager = Convert.ToInt32(ViewState["pageindex"]);
        int intRows = 0;
        if (numberpager == 0)
        {
            intRows = Convert.ToInt32(e.RowIndex);
        }
        else if (dt.Rows.Count == 10)
        {
            intRows = Convert.ToInt32(e.RowIndex);
        }
        else
        {
            intRows = (Convert.ToInt32(e.RowIndex) + (numberpager * 10));
        }

        int temp = e.RowIndex;
        int ID = Convert.ToInt32(dt.Rows[intRows]["ID"]);
        int 団体ID = Convert.ToInt32(dt.Rows[intRows]["団体ID"]);
        int 企業ID = Convert.ToInt32(dt.Rows[intRows]["企業ID"]);
        int 応募情報ID = Convert.ToInt32(dt.Rows[intRows]["応募情報ID"]);
        if (frmJ_TraineeAppAssignCheck_Delete(ID, 団体ID, 企業ID, 応募情報ID) == 1)
        {
            BindDDLGridView();
        }

    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Check delete data in table 面接詳細情報
    /// </summary>
    /// <param name="ID"></param>
    /// <param name="団体ID"></param>
    /// <param name="企業ID"></param>
    /// <param name="応募情報ID"></param>
    /// <returns></returns>
    public int frmJ_TraineeAppAssignCheck_Delete(int ID, int 団体ID, int 企業ID, int 応募情報ID)
    {
        if (_面接詳細情報Manager.frmJ_TraineeAppAssignCheck_Delete(ID, 団体ID, 企業ID, 応募情報ID) == 1)
        {
            return 1;
        }
        return 0;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Event: Click ddl_組合選択 load ddl_組合員企業選択 where 企業ID
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ddl_組合選択_SelectedIndexChanged(object sender, EventArgs e)
    {

        Load_ddl_組合員企業選択(Convert.ToInt32(ddl_組合選択.SelectedValue));
        Load_面接日(Convert.ToInt32(ddl_組合選択.SelectedValue), Convert.ToInt32(ddl_組合員企業選択.SelectedValue));
        if (hd_BrowserVer.Value == "true")
        {
            ddl_組合員企業選択.Focus();
        }
        else
        {
            ddl_組合選択.Focus();
        }
        string strTableHeader = "氏名,年齢,数学テスト,性格（YG),最終学歴,ID発行機関,組合名,企業名";
        ShowGridViewNotClassEmpty(grv, strTableHeader, "データがありません。");
        ViewState["update"] = 0;
        ScriptManager.RegisterStartupScript(up_組合員企業選択1, GetType(), "Javascript", "javascript: RegisterPage(); ", true);
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Event: Click ddl_組合名 load ddl_企業名 where 企業ID
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ddl_組合名_SelectedIndexChanged(object sender, EventArgs e)
    {
        int abc = Convert.ToInt32(((DropDownList)sender).SelectedValue);
        int rowIndex = Convert.ToInt32(((DropDownList)sender).ValidationGroup);
        Control ctrl1 = grv.Rows[rowIndex].FindControl("ddl_組合名");
        DropDownList dd1 = ctrl1 as DropDownList;
        dd1.BackColor = Color.White;
        Control ctrl2 = grv.Rows[rowIndex].FindControl("ddl_企業名");
        if (ctrl2 != null)
        {
            DropDownList dd = ctrl2 as DropDownList;
            //Binding the Dropdown with Dummy data.
            DataTable dt1 = new DataTable();
            dt1 = _本社情報Manager.frmJ_TraineeSearch_Select_dll組合員企業選択(abc);
            dd.DataSource = dt1;
            dd.DataTextField = "企業名";
            dd.DataValueField = "企業ID";
            dd.DataBind();
            ListItem item = new ListItem("[選択]", "-1");
            item.Selected = true;
            dd.Items.Insert(0, item);
        }

    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Check exitst dropdowlist empty
    /// </summary>
    /// <param name="grvcheck"></param>
    /// <returns></returns>
    public bool CheckddlEmpty(GridView grvcheck)
    {

        for (int i = 0; i < grvcheck.Rows.Count; i++)
        {
            Control ctrl1 = grvcheck.Rows[i].FindControl("ddl_組合名");
            DropDownList dd1 = ctrl1 as DropDownList;
            Control ctrl2 = grvcheck.Rows[i].FindControl("ddl_企業名");
            DropDownList dd2 = ctrl2 as DropDownList;
            if (dd1.SelectedValue == "-1" || dd2.SelectedValue == "-1")
            {
                return false;
            }
        }
        return true;
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Change background when dropdowlist empty
    /// </summary>
    /// <param name="grvCheck"></param>
    public void ChangeBackgroundDropdowlistEmpty(GridView grvCheck)
    {
        for (int i = 0; i < grvCheck.Rows.Count; i++)
        {
            Control ctrl1 = grvCheck.Rows[i].FindControl("ddl_組合名");
            DropDownList dd1 = ctrl1 as DropDownList;
            Control ctrl2 = grvCheck.Rows[i].FindControl("ddl_企業名");
            DropDownList dd2 = ctrl2 as DropDownList;
            if (dd1.SelectedValue == "-1")
            {
                dd1.BackColor = Color.Red;
            }
            else
            {
                dd1.BackColor = Color.White;
            }
            if (dd2.SelectedValue == "-1")
            {
                dd2.BackColor = Color.Red;
            }
            else
            {
                dd2.BackColor = Color.White;
            }
        }
    }

    /// <summary>
    /// Coder: Thanh Dong
    /// Function: Convert number to string
    /// Status: OK
    /// </summary>
    /// <param name="temp"></param>
    /// <returns></returns>
    public string Show最終学歴(string temp)
    {
        string strResult = "";
        switch (temp)
        {
            case "0":
                strResult = "博士";
                break;
            case "1":
                strResult = "修士";
                break;
            case "2":
                strResult = "学士";
                break;
            case "3":
                strResult = "高専";
                break;
            case "4":
                strResult = "高校";
                break;
            default:
                strResult = "中学";
                break;
        }
        return strResult;
    }



    /// <summary>
    /// Coder: Thanh Dong
    /// Event: Change background color onclick
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ddl_企業名_SelectedIndexChanged(object sender, EventArgs e)
    {
        int rowIndex = Convert.ToInt32(((DropDownList)sender).ValidationGroup);
        Control ctrl1 = grv.Rows[rowIndex].FindControl("ddl_企業名");
        DropDownList dd1 = ctrl1 as DropDownList;
        if (dd1.SelectedValue != "-1")
        {
            dd1.BackColor = Color.White;
        }
    }


    /// <summary>
    /// Coder: Thanh Dong
    /// Envent: Click ddl_組合員企業選択 show gridview empty
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ddl_組合員企業選択_SelectedIndexChanged(object sender, EventArgs e)
    {
        Load_面接日(Convert.ToInt32(ddl_組合選択.SelectedValue), Convert.ToInt32(ddl_組合員企業選択.SelectedValue));
        ddl_面接日.Focus();
        string strTableHeader = "氏名,年齢,数学テスト,性格（YG),最終学歴,ID発行機関,組合名,企業名";
        ShowGridViewNotClassEmpty(grv, strTableHeader, "データがありません。");
        ScriptManager.RegisterStartupScript(up_組合員企業選択1, GetType(), "Javascript", "javascript: RegisterPage(); ", true);
    }
    
    /// <summary>
    /// Coder: Thanh Dong
    /// Event: Textbox change show gridview empty
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>

    public DataTable frmJ_TraineeAppAssignCheck_面接日(int 団体ID, int 企業ID)
    { 
        return _面接情報Manager.frmJ_TraineeAppAssignCheck_面接日(団体ID, 企業ID);
    }

    public void Load_面接日(int 団体ID, int 企業ID)
    {
        DataTable dt = new DataTable();
        dt = frmJ_TraineeAppAssignCheck_面接日(団体ID, 企業ID);
        DataColumn dc = new DataColumn("Data", Type.GetType("System.String"));
        dt.Columns.Add(dc);
        hd_Calender.Value = "";
        foreach (DataRow row in dt.Rows)
        {
            string result = row["面接日"].ToString();
            hd_Calender.Value += row["面接日"].ToString().Substring(0,10) +",";
            row["Data"] = result;
        }
        ddl_面接日.DataSource = dt;
        ddl_面接日.DataTextField = "Data";
        ddl_面接日.DataValueField = "面接日";
        ddl_面接日.DataBind();
        ListItem item = new ListItem("[選択]", "-1");
        item.Selected = true;
        ddl_面接日.Items.Insert(0, item);
        
    }
    protected void ddl_面接日_SelectedIndexChanged(object sender, EventArgs e)
    {
        //btn検索.Focus();
        //string strTableHeader = "氏名,年齢,数学テスト,性格（YG),最終学歴,ID発行機関,組合名,企業名";
        //ShowGridViewNotClassEmpty(grv, strTableHeader, "データがありません。");
        //ScriptManager.RegisterStartupScript(up_組合員企業選択1, GetType(), "Javascript", "javascript: RegisterPage(); ", true);
        DateTime dt = new DateTime();
        DateTime.TryParse(Convert.ToString(ddl_面接日.SelectedValue), out dt);
        if (String.Format("{0:yyyy/MM/dd}", dt) == "0001/01/01")
        {
            string strTableHeader = "氏名,年齢,数学テスト,性格（YG),最終学歴,ID発行機関,組合名,企業名";
            ShowGridViewNotClassEmpty(grv, strTableHeader, "データがありません。");
        }
        else
        {
            ShowGrv(Convert.ToInt32(ddl_組合選択.SelectedValue), Convert.ToInt32(ddl_組合員企業選択.SelectedValue), Convert.ToDateTime(ddl_面接日.SelectedValue));
            BindDDLGridView();
            ViewState["pageindex"] = 0;
        }
        ScriptManager.RegisterStartupScript(up_組合員企業選択1, GetType(), "Javascript", "javascript: RegisterPage(); ", true);
    }
}
